﻿//using com.igetui.api.openservice;
//using com.igetui.api.openservice.igetui;
//using com.igetui.api.openservice.igetui.template;
//using System.Collections.Generic;
//using System.Linq;

//namespace JNPF.Utils
//{
//    /// <summary>
//    /// 消息推送 - APP
//    /// 版 本：V3.0.0
//    /// 版 权：引迈信息技术有限公司（https://www.jnpfsoft.com）
//    /// 作 者：JNPF开发平台组
//    /// </summary>
//    public class GetuiAppPushHelper
//    {
//        /// <summary>
//        /// 静态实例
//        /// </summary>
//        public static GetuiAppPushHelper Instance
//        {
//            get { return new GetuiAppPushHelper(); }
//        }
//        private static string HOST = "http://sdk.open.api.igexin.com/apiex.htm";
//        private static string APPID = ConfigurationKey.igexin_appid;
//        private static string APPKEY = ConfigurationKey.igexin_appkey;
//        private static string MASTERSECRET = ConfigurationKey.igexin_mastersecret;
//        private static TransmissionTemplate TransmissionTemplate(string transmissionContent)
//        {
//            var template = new TransmissionTemplate();
//            template.AppId = APPID;
//            template.AppKey = APPKEY;
//            template.TransmissionContent = transmissionContent;
//            return template;
//        }
//        /// <summary>
//        /// 发送通知
//        /// </summary>
//        /// <param name="tenantId">tenantId</param>
//        /// <param name="toUserId">用户</param>
//        /// <param name="title">标题</param>
//        /// <param name="content">内容</param>
//        /// <param name="payload">类型：1-公告、2-消息、3-IM</param>
//        public void SendNotice(string tenantId, List<string> toUserIds, string title, string content, string payload)
//        {
//            if (!ConfigurationKey.igexin_enabled)
//                return;
//            var mobileDeviceData = new Dictionary<string, string>();
//            var deviceKeys = CacheFactory.Cache.GetHashKeys(CacheKey.MOBILEDEVICELIST);
//            var deviceValues = CacheFactory.Cache.GetHashValues(CacheKey.MOBILEDEVICELIST);
//            for (int i = 0; i < deviceValues.Count; i++)
//            {
//                mobileDeviceData.Add(deviceKeys[i], deviceValues[i]);
//            }
//            var clientIds = new List<string>();
//            foreach (var item in toUserIds)
//            {
//                var clientId = mobileDeviceData.FirstOrDefault(q => q.Key == item).Value;
//                if (!string.IsNullOrEmpty(clientId))
//                {
//                    clientIds.Add(clientId);
//                }
//            }
//            IGtPush push = new IGtPush(HOST, APPKEY, MASTERSECRET);
//            TransmissionTemplate templateNoti = TransmissionTemplate("{ \"title\": \"" + title + "\",\"content\": \"" + content + "\",\"payload\": \"" + payload + "\"}");
//            ListMessage message = new ListMessage();
//            message.IsOffline = true;
//            message.OfflineExpireTime = 1000 * 3600 * 12;
//            message.Data = templateNoti;
//            List<Target> targetList = new List<Target>();
//            foreach (var clientId in clientIds)
//            {
//                Target target = new Target();
//                target.appId = APPID;
//                target.clientId = clientId;
//                targetList.Add(target);
//            }
//            var contentId = push.getContentId(message);
//            var pushResult = push.pushMessageToList(contentId, targetList);
//        }
//    }
//}
